package com.cskaoyan.controller;

import com.cskaoyan.bean.issue.bo.QueryIssueBo;
import com.cskaoyan.bean.issue.bo.UpdateIssueBo;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.service.issue.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 创建日期: 2022/05/06 20:58
 *
 * @author JinLu Zhou
 */
@RestController
@RequestMapping("admin/issue")
public class IssueController {
    @Autowired
    IssueService issueService;

    @RequestMapping("list")
    public BaseRespVo list(QueryIssueBo queryIssueBo) {

        return issueService.issueList(queryIssueBo);
    }


    @RequestMapping("create")
    public BaseRespVo create(@RequestBody Map map) {
        String answer = (String) map.get("answer");
        String question = (String) map.get("question");
        return issueService.createIssue(answer,question);
    }

    @RequestMapping("update")
    public BaseRespVo update(@RequestBody UpdateIssueBo updateIssueBo) {
        return issueService.updateIssue(updateIssueBo);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody UpdateIssueBo updateIssueBo) {
        return issueService.deleteIssue(updateIssueBo);
    }
}
